跳到主要内容

企业钱包API文档

介绍

欢迎来到 OpenBlock 开发者文档!

您可以通过 OpenBlock API:

  • 创建/审批交易
  • 获取企业钱包资产余额和交易历史
  • 接收企业钱包相关事件的 webhook 通知
  • ......

与传统方法相比,通过 API 进行操作可以提高效率,降低成本,并实现企业钱包的自动化管理。

欢迎使用 OpenBlock API 管理您的钱包,我们提供完善的文档和示例代码,也有专业的技术支持团队为您提供帮助。

接入指南

概述

请使用具有企业钱包管理的用户账户登录OpenBlock并切换到企业钱包,进入企业钱包管理页面,在左侧栏 API 标签页进行管理付费计划、 API 账户创建和Webhook 配置,API 账户创建成功后,可以使用 API Key 来访问企业钱包API。


API 鉴权

GET 请求

GET 请求签名步骤:

  1. 设所有发送或者接收到的数据为集合 M,为集合 M 添加一个 nonce 参数,nonce 的值可取 uuid。

  2. 将集合 M 内非空参数的值的参数按照参数名 ASCII 码从小到大排序(字典序),使用 URL 键值对的格式(即 key1=value1&key2=value2...)拼接成字符串 stringA。

    特别注意:

    • 参数名 ASCII 码从小到大排序(字典序)

    • 如果参数的值为空不参与签名

    • 参数名区分大小写

  3. 在 stringA 最后拼接上 api_key 得到 stringSignTemp 字符串。

  4. 使用 api_secret 对 stringA 取 SHA256 的大写 16 进制字符串得到本次请求的签名 sign 值。

  5. 在 stringSignTemp 字符串后拼接 &sign=sign 得到最终签名串。

实例:

假设用户的 api_key 为:kkkkkkkkk,api_secret 为:ccccccccc。某次请求的原始 url 为 openapi.openblock.com/api/v1/xxx?a=111&b=222&c=333。

  1. 添加 nonce 后排序得到字符串 stringA:a=111&b=222&c=333&nonce=09B7D140-9A8A-4D31-82CF-8B343B2301A7。

  2. 为 stringA 拼接 api_key 得到 stringSignTemp:a=111&b=222&c=333&nonce=09B7D140-9A8A-4D31-82CF-8B343B2301A7&api_key=kkkkkkkkk。

  3. 使用 api_secret 对 stringSignTemp 取大写 16 进制 SHA256 得到 sign:85F79F53AC252C8547CD2866C09BA9A6F66ABA0407E84E1DDAED16A97C9ACDC7。

  4. 为 stringSignTemp 拼接 sign:a=111&b=222&c=333&nonce=09B7D140-9A8A-4D31-82CF-8B343B2301A7&api_key=kkkkkkkkk&sign=85F79F53AC252C8547CD2866C09BA9A6F66ABA0407E84E1DDAED16A97C9ACDC7。

  5. 签名结束。

POST 请求

POST 请求签名步骤:

  1. 与 GET 请求的处理相同。

  2. 将 nonce、api_key、sign 放在 body 中。

  3. 若 body 为 JSON 格式,则直接在 JSON 中添加对应的键值。

    实例:

    假设用户的 api_key 为:kkkkkkkkk,api_secret 为:ccccccccc。某次请求的 body 为:

{
"a": "111",
"b": "222",
"c": "333"
}
  1. 添加 nonce 后排序得到字符串 stringA:a=111&b=222&c=333&nonce=08AE0435-E68B-4460-835B-15475B58B75C。

  2. 为 stringA 拼接 api_key 得到 stringSignTemp:a=111&b=222&c=333&nonce=08AE0435-E68B-4460-835B-15475B58B75C&api_key=kkkkkkkkk。

  3. 使用 api_secret 对 stringSignTemp 取大写 16 进制 SHA256 得到 sign:7D2D6314B659E96A0A406C5837C94D0AC2901192BFEE2C03E7763D710525D980。

  4. 重新构建 JSON:

{
"a": "111",
"b": "222",
"c": "333",
"nonce":"08AE0435-E68B-4460-835B-15475B58B75C",
"api_key":"kkkkkkkkk",
"sign":"7D2D6314B659E96A0A406C5837C94D0AC2901192BFEE2C03E7763D710525D980"
}

签名结束。


IP 白名单

在调用企业钱包API时,只允许从您设置的 IP 白名单地址发起请求,您需要在创建 API Key 时设置调用发起的 IP 地址。


请求 base URL

https://auth.openblock.com

API 列表

获取企业钱包信息

接口说明

接口类型接口地址请求方法
Restful/openapi/company_wallet/info/GET

输入参数说明

输出参数说明

字段名类型描述
company_wallet_infoobject企业钱包信息
--company_wallet_idstring企业钱包ID
--wallet_namestring企业钱包名称
--team_admin_membersint管理员成员数
--policy_membersint政策成员数
rolestring用户角色,枚举值:ADMIN/SUPER_ADMIN/GENERAL
address_listlist链地址列表
--chainstring链名称
--addressstring链地址
hd_wallet_listlist子列包列表
--hd_wallet_idstring子钱包ID
--wallet_namestring子钱包名称

成功返回示例

{
"company_wallet_info":{
"company_wallet_id":"xxx",
"wallet_name":"企业钱包1",
"team_admin_members":2,
"policy_members":1
},
"role":"ADMIN",
"address_list":[
{
"chain":"ETH",
"address":"xxxxx"
},
{
"chain":"Polygon",
"address":"xxxxx"
}
],
"hd_wallet_list":[
{
"hd_wallet_id":"xxxx",
"wallet_name":"子钱包1"
},
{
"hd_wallet_id":"xxxx",
"wallet_name":"子钱包2"
}
]
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

获取企业钱包子钱包地址

接口说明

接口类型接口地址请求方法
Restful/openapi/company_wallet/hd_wallet_address/GET

输入参数说明

参数名是否必传类型描述
hd_wallet_idstring企业钱包子钱包id

输出参数说明

字段名类型描述
address_listlist链地址列表
--chainstring链名称
--addressstring链地址

成功返回示例

{
"address_list":[
{
"chain":"ETH",
"address":"xxxxx"
},
{
"chain":"Polygon",
"address":"xxxxx"
}
]
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

获取钱包余额

接口说明

接口类型接口地址请求方法
Restful/openapi/company_wallet/balance/GET

输入参数说明

参数名是否必选类型默认值描述
chain_namestring区块链名称
currencystringUSD本位货币,枚举值:CNY,USD
hd_wallet_idstring企业钱包子钱包id,不传时为主钱包
pageint0分页页数
limitint20分页大小

输出参数说明

字段名类型描述
totalint总记录数
assetsarray资产列表
- token_addressstring代币地址
- balancestring余额
- decimalint小数位数
- symbolstring代币符号
- currency_amountstring折算成本位货币的余额
- pricestring单价

成功返回示例

{
"total": 5,
"assets": [
{
"token_address": "",
"balance": "0.003904238820258",
"decimal": 18,
"symbol": "ETH",
"currency_amount": "7.038835022814874345458984375",
"price": "1802.8699951171875"
},
{
"token_address": "0xe3c408bd53c31c085a1746af401a4042954ff741",
"balance": "0",
"decimal": 8,
"symbol": "GMT2",
"currency_amount": "0",
"price": "0"
},
{
"token_address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"balance": "0",
"decimal": 8,
"symbol": "WBTC",
"currency_amount": "0",
"price": "26700"
},
{
"token_address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"balance": "0",
"decimal": 6,
"symbol": "USDC",
"currency_amount": "0",
"price": "1.0010000467300415"
}
]
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

添加自定义代币

接口说明

接口类型接口地址请求方法
Restful/openapi/company_wallet/custom_token/POST

输入参数说明

参数名是否必选类型描述
chain_namestring区块链名称
hd_wallet_idstring企业钱包子钱包id,不传时为主钱包
sync_walletsint添加代币同步到当前企业钱包的其它钱包,0:不同步(默认),1:同步
token_datastringjson对象格式的代币数据,转字符串
- addressstring代币合约地址
- symbolstring代币符号
- decimalsstring代币小数点位数

输出参数说明

字段名类型描述
messagestringok

输入参数示例

{
"chain_name":"eth",
"token_data":"{\"address\": \"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599\", \"symbol\": \"WBTC\", \"decimals\": \"8\"}"
}

成功返回示例

{
"message": "ok"
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

交易历史

接口说明

接口类型接口地址请求方法
Restful/openapi/company_wallet/tx_history/GET

输入参数说明

参数名是否必选类型描述
chain_namestring区块链名称
pageint分页页数,默认0
limitint分页大小,默认20
order_bystring排序字段,枚举值:tx_time, block_number, 默认tx_time
ascint排序顺序,0降序,1升序,默认0
hd_wallet_idstring企业钱包子钱包id,不传时为主钱包

输出参数说明

字段名类型描述
pageint当前页码
limitint每页数据条数
totalint总的数据条数
dataarray交易记录列表
- record_idstring交易记录ID
- block_hashstring区块hash
- block_numberstring区块高度
- chain_namestring链名称
- transaction_hashstring交易hash
- transaction_typestring交易类型
- contract_addressstring合约地址
- statusstring状态
- tx_timeint交易时间戳
- fromstring来源地址
- tostring目标地址
- amountstring金额
- fee_amountstring手续费金额
- fee_datastring手续费数据
- dapp_datastringdapp数据
- event_logstring事件日志
- parse_datastring解析后数据
- client_datastring客户端数据
- operate_typestring操作类型
- transfer_idstring转账ID
- approve_logic_datastring授权逻辑数据
- company_wallet_approve_logic_datastring公司钱包授权逻辑数据

成功返回示例:

{
"page": 0,
"limit": 1,
// 总的交易历史条目数量
"total": "6",
"data": [
{
"record_id": "1687743465",
"block_hash": "00000000031f2a40fc2741ee3c27484651e1052a99f9403d3ea08093fb99606f",
"block_number": "52374080",
"chain_name": "TRX",
"transaction_hash": "fee60897259e350c59805ac557019ade18e3c0971fa4d7528f74960ea2860d8a",
"transaction_type": "native",
"contract_address": "",
// 枚举值: success,
"status": "success",
// 时间戳, 单位秒
"tx_time": 1687743465,
"from": "TYuUmUBnqTGia5jjrmvUJieTUiTVvXEn4Z",
"to": "TSHGQ4sDHtYYawVuwAJh1d5yWc21BBonhE",
"amount": "1",
"fee_amount": "0",
"fee_data": "{\"energy_usage\":\"0\",\"fee_limit\":\"0\",\"net_usage\":\"265\"}",
"dapp_data": "",
"event_log": "",
"parse_data": "{\"token\":{\"address\":\"\",\"amount\":\"\",\"decimals\":0,\"symbol\":\"\"},\"tvm\":{}}",
"client_data": "",
"operate_type": "",
"transfer_id": "",
"approve_logic_data": "",
"company_wallet_approve_logic_data": null
},
]
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

获取审批列表

接口说明

接口类型接口地址请求方法
Restful/openapi/company_wallet/approvals/GET

输入参数说明

参数名是否必选类型默认值描述
pageint1分页页数
limitint20分页大小,最大20
statusstringING审批状态,ING:进行中,FINISH:已完成

输出参数说明

字段名类型描述
pageint当前页码
limitint每页数量
dataarray审批记录列表
- cursorint记录游标
- record_idstring审批记录ID
- origin_record_idstring原始审批记录ID
- my_statusstring我的审批状态
- statusstring审批总状态
- company_wallet_idstring企业钱包ID
- hd_wallet_idstringhd钱包ID
- wallet_namestring企业钱包名称
- approve_typestring审批类型
- action_typestring操作类型
- origin_user_uuidstring发起人用户ID
- origin_user_accountstring发起人账号
- create_timestring创建时间
- extra_dataobject额外数据
-- txinfoobject交易信息

成功返回示例

{
"page": 3,
"limit": 1,
"data": [
{
"cursor": 28540,
"record_id": "7ce4b20f3d694ed38b74c1bf004a78e9",
"origin_record_id": "c4ee8c6b39844726a9216739f9cc211c",
"my_status": "REJECT",
"status": "REJECT",
"company_wallet_id": "81bb6cba42254be79aeabf5cfd23a90b",
"wallet_name": "企业钱包二期v1-1-1",
"approve_type": "TRANSACTION_APPROVE",
"action_type": "TRANSACTION",
"origin_user_uuid": "08f0d83dfe024d69af6bfaf9d5a592e4",
"origin_user_account": "P2",
"create_time": "2023-07-03 09:54:10",
"extra_data": {
"txinfo": {
"eip1559": true,
"to": "0xEC4fD89cf3aCf436Fe3be0310C3caa5834A04FE4",
"tokenAddress": "",
"from": "0xB2eC55D4756Ff87333bE6B7b7E273d5Cec0C9180",
"value": "0.00001",
"nonce": "34",
"gasLimit": "21000",
"gasPrice": "0",
"maxFeePerGas": "0.000000293",
"maxPriorityFeePerGas": "0.000000276",
"unit": "GWEI",
"shortHost": "",
"chain": "ETHGoerliTEST",
"isNative": true,
"token": {},
"data": "",
"google_record_id": "44e4fd99e91b4042af32836b884fca75",
"transaction_type": "native",
"isEnterpriseWallet": true,
"amount": "0.00001",
"symbol": "ETH",
"totalGas": "0.000000000006153",
"nativeCurrency": "ETH",
"txinput": {
"chainId": "BQ==",
"txMode": 1,
"maxInclusionFeePerGas": "ARQ=",
"maxFeePerGas": "ASU=",
"gasLimit": "Ugg=",
"nonce": "Ig==",
"transaction": {
"transfer": {
"amount": "CRhOcqAA"
}
},
"toAddress": "0xEC4fD89cf3aCf436Fe3be0310C3caa5834A04FE4"
},
"getPriceKey": "ethereum"
}
}
}
]
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

创建交易相关审批

接口说明

接口描述:创建交易审批

接口类型接口 URL / PathHttp Method
restful/openapi/company_wallet/approval/new/POST

输入参数说明

参数名是否必传类型描述
actionstring审批类型
TRANSACTION = "转账"
TRANSACTION_APPROVE = "授权"
TRANSACTION_CONTRACT_INTERACTION = "合约交互"
hd_wallet_idstring企业钱包子钱包id,不传时为主钱包
txinfostring(json对象转字符串)交易参数
--transaction_typestring交易类型
native:主币转账
transfer:代币转账
approve:代币授权
contract:合约交互
transferNFT:nft转账
approveNFT:nft授权
--chainstring链名称
支持以下链:
BTC
ETH
BSC
SUI
Aptos
DOGE
Kaspa
Solana
TRX
Cosmos
Osmosis
Conflux
ETC
LTC
OEC
HECO
Fantom
Polygon
Avalanche
Cronos
Klaytn
xDai
Optimism
Arbitrum
ArbitrumNova
zkSync
SmartBCH
Harmony
Ronin
Nervos
Casper
Polkadot
STC
ETHGoerliTEST
BSCTEST
SUITEST
zkSyncTEST
ScrollL2TEST
SeiTEST
evm210425
--fromstring转出地址
--tostring转入地址
--tokenAddressstringtoken地址,代币转帐、dapp取消授权、nft转账、nft取消授权时必填
--valuestring转账金额,主币转帐、代币转帐、dapp主币转代币、nft转帐时必填
--noncestring自定义nonce
--gasLimitstring上链参数gasLimit
--gasPricestring上链参数gasPrice
--maxPriorityFeePerGasstring上链参数maxPriorityFeePerGas
--maxFeePerGasstring上链参数maxFeePerGas
--datastringdapp授权、nft授权、合约交互时必填
--pretreatment_valuestring预交易值,eth,bsc,arb,polygon 这几条链的合约交互时填写,
如果这几条链不填该值,则无法解析预交易详细内容的情况,将按照“大额交易审批”(若有)审批流进行审批。
--token_idstringnft转账时必填
--dappInfoobjectdapp信息
----originstringdapp源
----hrefstringdapp地址
----portNamestringdapp port name
----iconstringdapp图标
----dappNamestringdapp名称

加速、取消输入参数说明

参数名是否必传类型描述
txinfoobject交易参数
--original_record_idstring原交易的审批记录origin_record_id
--operate_typestring操作类型,speed_up:加速,cancel:取消
--gasLimitstring上链参数gasLimit
--gasPricestring上链参数gasPrice
--maxPriorityFeePerGasstring上链参数maxPriorityFeePerGas
--maxFeePerGasstring上链参数maxFeePerGas

输出参数说明

参数名类型描述
origin_record_idstring发起人的审批记录ID
record_idstring自动通过的审批详情id,有自动通过时返回
is_auto_passstring是否全部自动通过

入参示例

发起普通转账--原生币

{
"action": "TRANSACTION",
# 这个txinfo字段需要将 json 数据转为字符串,这里展示明文,仅供参考
"txinfo" :JSON.stringify({
"chain": "HECO",
"from": "0x5adE66b500B80070F3280198CEBA2Af830D8e0ab",
"to": "0x7620E9bbb6591b9F53b6b5002B716B8D23ca3950",
"value": "0.01",
"gasLimit": "97839",
"gasPrice":"0",
"maxPriorityFeePerGas": "2.25",
"maxFeePerGas": "2.25"
})
}

发起普通转账--非原生币

{
"action": "TRANSACTION",
# 这个txinfo字段需要将 json 数据转为字符串,这里展示明文,仅供参考
"txinfo":JSON.stringify({
"to":"0x7620E9bbb6591b9F53b6b5002B716B8D23ca3950",
"tokenAddress":"0xa71edc38d189767582c38a3145b5873052c3e47a",
"from":"0x5adE66b500B80070F3280198CEBA2Af830D8e0ab",
"value":"0.0001",
"nonce":"14",
"gasLimit":"63262",
"gasPrice":"0",
"maxFeePerGas":"2.475",
"maxPriorityFeePerGas":"2.475",
"chain":"HECO"
})
}

发起dapp代币授权

{
"action": "TRANSACTION_APPROVE",
# 这个txinfo字段需要将 json 数据转为字符串,这里展示明文,仅供参考
"txinfo":JSON.stringify({
"from":"0x5adE66b500B80070F3280198CEBA2Af830D8e0ab",
"to":"0xa71edc38d189767582c38a3145b5873052c3e47a", //代币地址
"nonce":"14",
"gasLimit":"97839",
"maxPriorityFeePerGas":"2.25",
"maxFeePerGas":"2.25",
"chain":"HECO",
"data":"0x00000000",
"dappInfo":{
"origin":"https://app.dodoex.io",
"href":"https://app.dodoex.io/?from=USDT&network=heco&to=HT",
"portName":"https://app.dodoex.io1689171704045",
"icon":"https://dashboard-assets.dappradar.com/geRRcWz9IdTwSrm1/document/14738/dodo-dapp-exchanges-ethereum-logo_13c0bed361114265825072e6b01a2c03.png",
"dappName":"DODO"
}
})
}

发起dapp合约交互

{
"action": "TRANSACTION_CONTRACT_INTERACTION",
# 这个txinfo字段需要将 json 数据转为字符串,这里展示明文,仅供参考
"txinfo":JSON.stringify({
"from":"0x5adE66b500B80070F3280198CEBA2Af830D8e0ab",
"to":"0xbc3a8f63f311f3b005ff8afc1a26272faaba8d36", //dapp项目方合约地址
"nonce":"14",
"gasLimit":"354052",
"maxPriorityFeePerGas":"2.25",
"maxFeePerGas":"2.25",
"chain":"HECO",
"data":"0x301a3720000000000000000000000000",
"value":"0.0001",
"amount":"0.0001",
"dappInfo":{
"origin":"https://app.dodoex.io",
"href":"https://app.dodoex.io/?network=heco&from=HT&to=USDT",
"portName":"https://app.dodoex.io1689171328132",
"icon":"https://dashboard-assets.dappradar.com/geRRcWz9IdTwSrm1/document/14738/dodo-dapp-exchanges-ethereum-logo_13c0bed361114265825072e6b01a2c03.png",
"dappName":"DODO"
}
})
}

取消代币授权

action:TRANSACTION_APPROVE

txinfo:

{
"transaction_type": "approve",
"to": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"from": "0xd7f7Bf0dfCF8e6a3Fa9BB7013DcE5e3f6956c3cb", //dapp项目方合约地址
"nonce": "16",
"gasLimit": "299979",
"gasPrice": "0.11",
"maxFeePerGas": "0",
"maxPriorityFeePerGas": "0",
"chain": "Arbitrum",
"isCancelTokenApprove": true,
"tokenAddress": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8" //代币地址
}

NFT转账

action:TRANSACTION

txinfo:

{
"transaction_type": "transferNFT",
"to": "0x27D25bBDA38F681c34A514E74D4e193BC1c2f19E",
"from": "0xd7f7Bf0dfCF8e6a3Fa9BB7013DcE5e3f6956c3cb",
"value": "1",
"nonce": "15",
"gasLimit": "130977",
"gasPrice": "6.2964",
"maxFeePerGas": "0",
"maxPriorityFeePerGas": "0",
"chain": "xDai",
"token_id": "51004",
"tokenAddress": "0xCF964c89f509a8c0Ac36391c5460dF94B91daba5" //NFT合约地址
}

NFT授权

action:TRANSACTION_APPROVE

txinfo:

{
"transaction_type": "approveNFT",
"to": "0x44b3f42e2bf34f62868ff9e9dab7c2f807ba97cb", // NFT合约地址
"from": "0xd7f7Bf0dfCF8e6a3Fa9BB7013DcE5e3f6956c3cb",
"value": "0",
"nonce": "238",
"gasLimit": "60591",
"maxFeePerGas": "195.1387121",
"maxPriorityFeePerGas": "47.73988292",
"chain": "Polygon",
"data": "0x000000000",
"dappInfo": {
"origin": "https://opensea.io",
"href": "https://opensea.io/account",
"portName": "https://opensea.io1697038498545",
"icon": "https://dashboard-assets.dappradar.com/document/13/opensea-dapp-marketplaces-ethereum-logo_a3421ac6e32d529db3c8293f4cfa9bcd.png",
"tokenGasless": {},
"isBlackListedDapp": false,
"dappName": "OpenSea"
}
}

NFT取消授权

action:TRANSACTION_APPROVE

txinfo:

{
"transaction_type": "approveNFT",
"to": "0x1E0049783F008A0085193E00003D00cd54003c71", //DAPP项目方合约地址
"from": "0xd7f7Bf0dfCF8e6a3Fa9BB7013DcE5e3f6956c3cb",
"value": "0",
"nonce": "242",
"gasLimit": "35396",
"gasPrice": "0",
"maxFeePerGas": "84.86624019",
"maxPriorityFeePerGas": "41.21511274",
"chain": "Polygon",
"tokenAddress": "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", //NFT合约地址
"isCancelTokenApprove": true
}

加速

txinfo:

{
"gasLimit": "21000",
"gasPrice": "0",
"maxFeePerGas": "70",
"maxPriorityFeePerGas": "35",
"operate_type": "speed_up",
"original_record_id": "05104d9fe7c2410a95dd0261fc771111"
}

成功返回示例

{
"ok": true,
"data": {
"origin_record_id": "xxxx", #发起人的审批记录ID,
"is_auto_pass": true, #是否自动通过
"record_id": "xxx",
}
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

同意/拒绝审批

接口说明

接口描述:同意、拒绝审批。

接口类型接口 URL / PathHttp Method
restful/openapi/company_wallet/approval/agree/POST

输入参数说明

接口描述:

参数名是否必传类型描述
record_idstring审批记录详情ID,同意/拒绝都传
agreestringagree/reject

成功返回示例

{
"ok": true,
"data": {
"record_id": "xxxx",
"origin_record_id": "xxx", #发起人角度的记录ID
"status": "xxx",
}
}

失败返回示例

{
"ok": false,
"err_msg": "xxxx",
"err_code": xxxx
}

Webhook

Webhook 概述

通过 Webhook 主动通知该企业钱包发生的一些事件通知,若用户想接收通知,则可以在企业钱包API管理页面配置回调地址Webhook。


请求描述

采用与API key相同的鉴权方案,OpenBlock向用户配置的Webhook回调地址发送发送一个 POST 请求,HTTP 请求头中 Content-Typeapplication/json;charset=UTF-8 。用户收到Webhook 推送通知后,需要返回成功应答(HTTP状态码 200 ),成功应答的内容是success;平台在收到非成功状态码时,会认为此次推送失败,会再次进行重试推送,再次推送的频率为 30s,1m,5m,1h,12h,24h。


事件格式

参数字段类型描述
event_typestring回调事件类型
event_detailobject回调事件详情

事件类型

序号event_type描述
1CREATE_TRANSACTION创建转账交易(调用approval/new接口)
2TRANSACTION_STATUS_CHANGE交易状态变更(拒绝,全体同意)

event_detail参数说明

参数名类型描述
record_idstring审批记录id
company_wallet_idstring企业钱包id
wallet_namestring企业钱包名称
action_typestring审批类型
TRANSACTION = "转账"
approve_typestring审批决策
SINGLE_APPROVE = '单人审批'
DESCISION_APPROVE = '决策模型审批'
ALL_ADMIN_APPROVE = '全部管理员审批'
TRANSACTION_APPROVE = '交易审批流'
status该条审批的状态
ING = "审批中"
TRADING = "仅同意未调用action" # 交易相关的审批的中间状态
AGREE = "同意"
REJECT = "驳回"
DELETED = "删除"
CANCEL = "取消"
AUTO_TRADING = "自动审批,仅同意未调用action" # 交易相关的审批的中间状态 TIMEOUT = "超时"
extra_dataobject扩展数据
--txinfoobject交易参数
agree_listlist已同意列表
ing_listobject进行中列表

txinfo参数说明

参数名类型描述
fromstring发送地址
tostring接收地址
tokenAddressstringtoken地址
valuestring交易金额(数量)
noncestringNonce
gasLimitstringgasLimit
gasPricestringgasPrice
maxFeePerGasstringmaxFeePerGas
maxPriorityFeePerGasstringmaxPriorityFeePerGas
chainstring链名称
isNativebool是否主币
transaction_typestring交易类型,native:主币转账,transfer:代币转账
amountstring交易金额
symbolstring主币符号
nativeCurrencystring主币名称

event_detail示例

{
"record_id":"672cbf141c0f4f988dec59678398a984",
"company_wallet_id":"2e3f75ebf9294fe68516f2d24cde74d3",
"wallet_name":"企业钱包1",
"approve_type":"TRANSACTION_APPROVE",
"action_type":"TRANSACTION",
"status":"ING",
"is_simple_type":false,
"create_time":"2023-07-16 23:02:22",
"is_sponsor":true,
"approve_title_type":"TRADE_APPROVE_MODIFY",
"expired_time":null,
"extra_data":{
"txinfo":{
"eip1559":true,
"to":"0x27652D40eA3393caB38263A3Bdf268265dB00e42",
"tokenAddress":"",
"from":"0x5adE66b500B80070F3280198CEBA2Af830D8e0ab",
"value":"0.001",
"nonce":"38",
"gasLimit":"21000",
"gasPrice":"0",
"maxFeePerGas":"2.475",
"maxPriorityFeePerGas":"2.475",
"unit":"GWEI",
"shortHost":"",
"chain":"HECO",
"isNative":true,
"token":{

},
"data":"",
"transaction_type":"native",
"isEnterpriseWallet":true,
"amount":"0.001",
"symbol":"HT",
"totalGas":"0.000051975",
"nativeCurrency":"HT",
"txinput":{
"chainId":"gA==",
"txMode":1,
"maxInclusionFeePerGas":"k4WAwA==",
"maxFeePerGas":"k4WAwA==",
"gasLimit":"Ugg=",
"nonce":"Jg==",
"transaction":{
"transfer":{
"amount":"A41+pMaAAA=="
}
},
"toAddress":"0x27652D40eA3393caB38263A3Bdf268265dB00e42"
},
"getPriceKey":"huobi-token"
}
},
"origin_user_id":"dbfb1c42e43f4a80b22409e9a5707344",
"origin_user_account":"cc",
"agree_list":[
{
"user_id":"dbfb1c42e43f4a80b22409e9a5707344",
"account":"xxx@gmail.com",
"nick_name":"cc",
"create_time":"2023-07-16 23:02:22",
"status":"init"
}
],
"ing_list":[
{
"node_name":"节点1",
"valid_users_number":2,
"total_users_number":2,
"status":"ING",
"user_list":[
{
"user_id":"dbfb1c42e43f4a80b22409e9a5707344",
"account":"xxx@gmail.com",
"nick_name":"cc",
"update_time":"2023-07-16 23:02:22",
"status":"AGREE"
},
{
"user_id":"00faf29f7d4744ee8a049110030a5cf3",
"account":"xxx@gmail.com",
"nick_name":"jj",
"update_time":"2023-07-16 23:02:22",
"status":"ING"
}
]
}
]
}

错误码

错误码错误描述
68000通用错误码,错误描述查看 err_msg
50001参数错误
50002nonce重复请求
50003无效的 api key
50004不可用的 api key
50005IP不允许访问
50006请求签名无效
50007无效的钱包
50008用户异常
50101审批记录不存在
50102审批记录未通过审批
50103原审批记录已完成

更多待补充

Docker API

该项目旨在为用户提供本地签名的能力,以便于用户可以在自己的服务器上部署钱包服务,而不是使用 Openblock 提供的钱包服务。

启动

首先,确保你已经安装了 Docker,然后执行以下命令:

docker pull openblock/openblock:1.0.0
docker run -p 7790:7790 -d openblock/openblock:1.0.0

使用

进入 http://localhost:7790,你将看到 MPC 单元的导入界面,按照提示导入你的 MPC 单元,导入成功后,你将看到你的企业钱包。

签名接口

API Description
PathMethod
/openapi/sign/send_transactionPOST
Query Parameters
NameRequiredDescription
keytrue企业钱包申请的 API_KEY
Body Parameters
NameTypeRequiredDescription
company_wallet_approve_record_idstringtrue企业钱包审批id
Successful Response Example
{
"code": 0,
"data": "",// txhash
}
Error Response Example
{
"code": 10001,
"message": "sign error"
}

API SDK

我们提供 golang/python 二种语言的 API SDK:

更新日志

2023-12-28 v1.0.4

  • 增加 Golang和Python SDK

2023-10-26 v1.0.3

  • 增加支持企业钱包hd钱包
  • 删除 获取一个用户账户下所有的企业钱包信息 接口,增加 获取企业钱包信息获取企业钱包子钱包地址 接口
  • 增加支持发起加速、取消审批

2023-10-13 v1.0.2

  • 增加支持evm dapp授权、合约交互、NFT授权、NFT转账交易类型

2023-09-20 v1.0.1

  • 新增docker 镜像,支持 send_transaction api(仅支持 evm networks)
  • 接口路径前缀变更,由 /oopenapi/v1 变为 /openapi

2023-07-31 v1.0.0

  • 创建文档
  • 新增 获取一个用户账户下所有的企业钱包信息获取钱包余额添加自定义代币交易历史获取审批列表创建交易相关审批同意/拒绝审批接口